package com.situ.water_pay;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.situ.water_Invoice.mapper.IvInvoiceMapper;
import com.situ.water_Invoice.pojo.IvIninvoice;
import com.situ.water_Invoice.pojo.IvInvoice;
import com.situ.water_Invoice.service.IvIninvoiceService;
import com.situ.water_Invoice.service.IvInvoiceService;
import com.situ.water_pay.mapper.PyBillMapper;
import com.situ.water_pay.pojo.PyBill;
import com.situ.water_pay.service.PyBillService;
import com.situ.water_user.pojo.UsUser;
import com.situ.water_user.service.UsUserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

/**
 * @date 2020/12/2 - 19:32
 */
@SpringBootTest
public class testSelect {
    @Autowired
    private PyBillService pyBillService;
    @Autowired
    private UsUserService usUserService;
    @Autowired
    private PaginationInterceptor paginationInterceptor;

    @Test
    public void test1() {
        //条件构造器
        QueryWrapper<UsUser> wrapper = new QueryWrapper<>();
        // UserName='伊人泪'
        // wrapper.eq("UserName","伊人泪");
        //like '%伊%'
        //wrapper.like("UserName", "伊");
        //分页
        //参数（当前页码，行数）
        Page<UsUser> page = new Page<UsUser>(1, 3);
        List<UsUser> users = usUserService.page(page, wrapper).getRecords();
        for (UsUser user : users) {
            System.out.println(user.getUsername());
        }
    }

    @Autowired
    private IvInvoiceService ivInvoiceService;

    @Test
    public void test2() {
        List<IvInvoice> list = new ArrayList<>();
        for (int i = 32856; i < 83184; i++) {
            String id = "020"+i;
            IvInvoice fp = new IvInvoice();
            fp.setInvoiceType(0);
//            fp.setInvoiceNo(id);
            fp.setInID(1);
            fp.setUsed(false);
            boolean b = ivInvoiceService.save(fp);
            System.out.println("发票"+fp.getInID()+"入库成功");
       }
    }
}
